package com.itheima.exception;


import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@Component
public class MyHandlerException implements HandlerExceptionResolver {

    @Override
    public ModelAndView resolveException(HttpServletRequest httpServletRequest,
                                         HttpServletResponse httpServletResponse,
                                         Object o,
                                         Exception e) {
        System.out.println("MyHandlerException");
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("msg","出错了");
        modelAndView.setViewName("error.jsp");
        return modelAndView;
    }
}
